-- @owner: wang-tianjing1
-- @date: 2025/8/11
-- @testpoint:subtype类型为已经存在的record类型,将其作为另一个record类型中的元素类型

--pre1:连接A库执行
@conn PrimaryDbAmode;
drop extension if exists gms_output;
create extension gms_output;
select gms_output.enable();
--step1: 创建package; expect:成功
CREATE OR REPLACE PACKAGE r_types AUTHID DEFINER IS TYPE r_type_1 IS RECORD (f VARCHAR2(5) := 'abcde');SUBTYPE r_type_2 IS r_type_1;END r_types;/
create or replace package pck1 is
type tp_1 is record(v01 number, v03 r_types.r_type_2, v02 number);
type tp_2 is varray(10) of int;
procedure p1(a tp_1,b out varchar2);
procedure p1(a2 tp_2, b2 out varchar2);
end pck1;
/
create or replace package body pck1 is
procedure p1(a tp_1,b out varchar2) is
begin
b:=a.v03.f;
raise info 'b:%',b;
end;
procedure p1(a2 tp_2, b2 out varchar2) is
begin
b2:=a2(2);
raise info 'b2:%',b2;
end;
end pck1;
/

--step2: 调用; expect: 成功
declare
var1 pck1.tp_1;
var varchar(100);
begin
var1.v01 := 2;
var1.v03.f='a';
var1.v02 := 3;
pck1.p1(var1,var);
gms_output.put_line('var: '|| var);
end;
/
drop extension if exists gms_output;
